#lang sicp
;; 2.66
(define (make-tree left entry right) (list left entry right))
(define (left-branch tree) (car tree))
(define (right-branch tree) (caddr tree))
(define (entry tree) (cadr tree))
(define (make-record key info) (list key info))
(define (key-record record) (car record))

(define (lookup given-key tree)
  (cond ((null? tree) #F)
        (else
         (let ((cur-key (key-record (entry tree))))
           (cond ((= cur-key given-key) (entry tree))
                 ((< cur-key given-key) (lookup given-key (right-branch tree)))
                 ((> cur-key given-key) (lookup given-key (left-branch tree))))))))

(define r1 (make-record 3 1))
(define r2 (make-record 5 1))
(define r3 (make-record 7 1))
(define r4 (make-record 11 1))
(define r5 (make-record 43 1))
(define r6 (make-record 766 1))
(define t1 (list (list (list '() r1 '()) r3 (list '() r2 '())) r4 (list '() r5 (list '() r6 '()))))
(define t2 (make-tree (make-tree nil r1 nil) r2 (make-tree nil r3 nil)))